package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.query.album.TrackInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {


    /**
     *  获取当前用户声音分页列表
     * @param trackListVoPage
     * @param query
     * @return
     */
    Page<TrackListVo> selectUserTrackPage(Page<TrackListVo> trackListVoPage, @Param("vo") TrackInfoQuery query);

    /**
     * 新声音顺序
     * @param orderNum
     * @param albumId
     */
    @Update(" update track_info  set order_num=order_num-1 where order_num>#{orderNum} and  album_id=#{albumId} and is_deleted=0 ")
    void updateOrderNum(Integer orderNum, Long albumId);

    IPage<AlbumTrackListVo> selectAlbumTrackPage(IPage<AlbumTrackListVo> trackPage, Long albumId);
}
